/**
 * 是否为http或者https开头的链接
 */
export const isLink = (str: string) => /^http(s?):\/\//.test(str);

/**
 * 是否为email
 */
export const isEmail = (str: string) => /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(str);

/**
 * 是否为手机号码
 */
export const isMobile = (str: string) => /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(str);

/**
 * 是否为URL
 */
export const isURL = (str: string) =>
    /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(str);

/**
 * 是否为IP(v4)地址
 */
export const isIP = (str: string) =>
    /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(str);
